"""
URL configuration for config project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/5.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""

from django.contrib import admin
from django.urls import path, include, re_path
from rest_framework.routers import DefaultRouter
from blog.views import ArticleViewSet, CategoryViewSet
from django.views.static import serve
from django.conf import settings
from learn.views import LearnViewSet
from account.views import CustomUserViewSet, AuthorViewSet
# from account.views import SendEmailCodeView, CheckEmailCodeView, CustomUserViewSet, ForgetPasswordView, AuthorViewSet
# 使用api路由管理
router = DefaultRouter()
router.register(r'blog', ArticleViewSet, basename='blog')
router.register(r'category', CategoryViewSet, basename='category')
# router.register(r'tag', TagsViewSet, basename='tag')
router.register(r'learn', LearnViewSet, basename='learn')
router.register(r'account', CustomUserViewSet, basename='account')
router.register(r'author', AuthorViewSet, basename='author')


urlpatterns = [
    path("admin/", admin.site.urls),
    # path('api/send-code/', SendEmailCodeView.as_view()),
    # path('api/check-code/', CheckEmailCodeView.as_view()),
    # path('api/forget-password/', ForgetPasswordView.as_view()),
    # path('api/password/reset/confirm/', CodePasswordResetConfirmView.as_view()),
    path('api/', include(router.urls)),
    # 注释掉默认的djoser用户路由，使用我们自定义的视图集替代
    path('api/', include('djoser.urls')),
    path('api/', include('djoser.urls.jwt')),
    path('api/markdownx/', include('markdownx.urls')),
    re_path(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}, name='media'),
]
